package com.example.es_promotion.repository;

import com.example.es_promotion.entity.Promotion;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import java.util.List;

public interface PromotionRepository extends JpaRepository<Promotion, Long> {
    
    List<Promotion> findByStatus(Integer status);
    
    @Query("SELECT p FROM Promotion p WHERE p.status = 1 AND p.startTime <= CURRENT_TIMESTAMP AND p.endTime >= CURRENT_TIMESTAMP")
    List<Promotion> findActivePromotions();
}